package cn.com.action;

import java.util.Map;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import cn.com.biz.ManagerBiz;
import cn.com.entity.Manager;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class ManagerAction extends ActionSupport{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Manager manager;
	private ManagerBiz managerbiz;
	private String  msg;
	public Manager getManager() {
		return manager;
	}
	public void setManager(Manager manager) {
		this.manager = manager;
	}
	
	public ManagerBiz getManagerbiz() {
		return managerbiz;
	}
	public void setManagerbiz(ManagerBiz managerbiz) {
		this.managerbiz = managerbiz;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	//登录功能
	public String managerLogin(){
		@SuppressWarnings("resource")
		ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext.xml");
		managerbiz=(ManagerBiz)ac.getBean("managerbiz");
		Map<String, Object> session=ActionContext.getContext().getSession();
		boolean bool=managerbiz.managerLogin(manager);
		if(bool){
			session.put("manager", manager);
			return SUCCESS;
		}
		else{
			setMsg("登录失败，密码或者用户名错误，请您重新登录！");
			return INPUT;
		}
	}
	
	
	
}
